package Adapter;

import java.io.*;

/**
 * 适配器例子
 */
public class adapter {
    public static void main(String[] args){

        // io的例子
        try {
            FileInputStream fi = new FileInputStream("/Users/yilianhudong/IdeaProjects/design/src/main/java/Adapter/test.text");

            // 适配器 InputStreamReader 现在的fi 没有办法直接共给 BufferedReader 所以需要转一下。
            InputStreamReader isr = new InputStreamReader(fi);

            BufferedReader bfr = new BufferedReader(isr);
            try {
                String line = bfr.readLine();
                while (line != null){
                    System.out.println(line);
                    line = bfr.readLine();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }


            try {
                fi.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {

        }
    }
}
